package com.feihong.newzxclient.config;

import android.content.Context;
import android.os.Environment;
import android.text.format.Time;

import java.io.File;

/**
 * @author hao.xiong
 * @version 1.0.0
 */
public class ZXConfig {

    private static String sDeviceId;
    private static String mRecordPath = "zaoxunlog/record";
    private static String mLogPath = "zaoxunlog/log";

    public static void init(Context context) {
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            mRecordPath = Environment.getExternalStorageDirectory() + File.separator + mRecordPath + File.separator;
            mLogPath = Environment.getExternalStorageDirectory() + File.separator + mLogPath + File.separator;
        } else {
            mRecordPath = context.getFilesDir() + File.separator + mRecordPath + File.separator;
            mLogPath = context.getFilesDir() + File.separator + mLogPath + File.separator;
        }
        new File(mRecordPath).mkdirs();
        new File(mLogPath).mkdirs();
    }

    public static void setDeviceId(String deviceId) {
        sDeviceId = deviceId;
    }

    public static String getDeviceId() {
        return sDeviceId;
    }

    public static String getRecordPath(final String suffix) {
        Time time = new Time();
        time.setToNow();
        return mRecordPath + time.format("%Y%m%d%H%M%S") + "." + suffix;
    }

    public static String getLogPath(final String suffix) {
        Time time = new Time();
        time.setToNow();
        return mLogPath + time.format("%Y%m%d%H%M%S") + "." + suffix;
    }
}
